package com.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：songxusheng
 * @date ：Created in 2022/3/10 10:32
 * @description：MQ的发布/订阅模式
 * @version: $
 */
@RestController
public class Topic_Produce {
    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Value("${consumerTopic}")
    private String mytopic;

    @PostMapping("sendTopic")
    public void sendTopic() {
        String msg="发送Topic消息内容 :"+"我是一条订阅消息";
        jmsMessagingTemplate.convertAndSend(mytopic, msg);
        System.out.println("订阅消息发送成功");
    }
}
